import { RealMsg } from "../common/realmsg";
import { Logger, LogFactory } from '../common/log';

async function main(){
    LogFactory.inst().init(process.cwd() + "/logs/", "log");
    let log = LogFactory.inst().getLogger("TestRealMsg");
    let realMsg = new RealMsg("localhost", 6379);
    await realMsg.subscribe("login:realmsg", async (channel:string, msg:string)=>{
        log.info(channel,msg);
    });
    await realMsg.subscribe("game:realmsg", async (channel:string, msg:string)=>{
        log.info(channel,msg);
    });
    for(let i=0; i<10; i++){
        await realMsg.publish("login:realmsg", "liliwang login at morning:"+i);
        await realMsg.publish("game:realmsg", "liliwang kill a monster:"+i);
    }
}
main();